﻿using System;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;

namespace YJKTools.ExportNavisworks
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	public class CmdExportNWC : IExternalCommand
	{
		public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elems)
		{
			try
			{
				int num = Convert.ToInt32(cmdData.Application.Application.VersionNumber);
				if (num < 2014)
				{
					msg = "此功能只在Revit2014及其以上版本可用。";
					return Autodesk.Revit.UI.Result.Failed;
				}
				if (!OptionalFunctionalityUtils.IsNavisworksExporterAvailable())
				{
					string text = string.Format("请安装Navisworks{0}软件。", num);
					TaskDialog.Show("盈建科", text);
					return Autodesk.Revit.UI.Result.Failed;
				}
				new ExportManager(cmdData).Export();
			}
			catch (Exception)
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
